let baseUrl = 'https://api-hmugo-web.itheima.net/api/'

function http(url, method = 'GET', data = {}) {
    return new Promise(function (reslove, reject) {
        wx.showLoading({
            title: '加载中...',
        })
        wx.request({
            url: baseUrl + url,
            method: method,
            data: data,
            success:function (res) {
                reslove(res)
            },
            fail:function (res) {
                reject(res)
            },
            complete(){
                setTimeout(function(){
                    wx.hideLoading()
                },1000)
            },
        })
    })
}
export default http;